﻿using System.Configuration;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using Project.Model.EF6.Entity;

namespace Project.Data
{
    public class EfContext : DbContext
    {
        public EfContext() : base("name=OracleDbContext")
        {
            Database.SetInitializer<EfContext>(null);
        }


        public IDbSet<ActiveConfig> ActiveConfig { get; set; }
        public IDbSet<ActiveRecord> ActiveRecord { get; set; }
        public IDbSet<SalesRecord> SalesRecord { get; set; }
        public IDbSet<AmountDay> AmountDay { get; set; }
        public IDbSet<AmountSemih> AmountSemih { get; set; }
        public IDbSet<RedDay> RedDay { get; set; }
        public IDbSet<RedSemih> RedSemih { get; set; }

        public IDbSet<RedWeek> RedWeek { get; set; }
        public IDbSet<RedMonth> RedMonth { get; set; }
        public IDbSet<AmountWeek> AmountWeek { get; set; }
        public IDbSet<AmountMonth> AmountMonth { get; set; }
        public IDbSet<Distributor> Distributor { get; set; }
        public IDbSet<PeopleWeek> PeopleWeek { get; set; }
        public IDbSet<PeopleMonth> PeopleMonth { get; set; }
        public IDbSet<PeopleDay> PeopleDay { get; set; }
        public IDbSet<PeopleSemih> PeopleSemih { get; set; }
        public IDbSet<IntegralWeek> IntegralWeek { get; set; }
        public IDbSet<IntegralMonth> IntegralMonth { get; set; }
        public IDbSet<IntegralDay> IntegralDay { get; set; }
        public IDbSet<IntegralSemih> IntegralSemih { get; set; }
        public IDbSet<DistributorWeek> DistributorWeek { get; set; }
        public IDbSet<DistributorMonth> DistributorMonth { get; set; }
        public IDbSet<DistributorDay> DistributorDay { get; set; }
        public IDbSet<DistributorSemih> DistributorSemih { get; set; }
        public IDbSet<ViscosityWeek> ViscosityWeek { get; set; }
        public IDbSet<ViscosityMonth> ViscosityMonth { get; set; }
        public IDbSet<ViscosityDay> ViscosityDay { get; set; }
        public IDbSet<UserOverview> UserOverview { get; set; }
        public IDbSet<MapUser> MapUser { get; set; }
        public IDbSet<Product> Product { get; set; }
        public IDbSet<ProductSemih> ProductSemih { get; set; }
        public IDbSet<ProductDay> ProductDay { get; set; }
        public IDbSet<ProductMonth> ProductMonth { get; set; }
        public IDbSet<ProductWeek> ProductWeek { get; set; }
        public IDbSet<ProductionReport> ProductionReport { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //去掉复数映射
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
            string schema = ConfigurationManager.AppSettings.Get("Schema");
            if (!string.IsNullOrEmpty(schema))
            {
                modelBuilder.HasDefaultSchema(schema);
            }
            base.OnModelCreating(modelBuilder);
        }
    }
}